#ifndef DEVICE_DATA_H
#define DEVICE_DATA_H

#include <QDialog>
#include"mqtthandler.h"
#include "globalval.h"
#include <QString>
#include <QFile>
#include <QFileInfo>
#include <QFileDialog>
#include <QThread>
#include "history.h"
#include <QVector>
#include <QPair>
struct ControlCommand
{
    int type;
    struct{
        int msg;
        int key;
        QString val;
    }data;
};
struct report{
    int type;
    int period;
};
struct address
{
    QString addr;
    int port;
};
struct stm32_data
{
    int key;
    QString name;
    int type;
};
struct modbus_data
{
    struct stm32_data mode_t;
    int addr;
};

namespace Ui {
class device_data;
}

class device_data : public QDialog
{
    Q_OBJECT

public:
    explicit device_data(QWidget *parent = 0);
    ~device_data();
    QString version;
    struct report rep;
    struct address mqtt_server;
    struct address mb_dev;
    struct stm32_data *stm;
    struct modbus_data *modb;

private:
    Ui::device_data *ui;
signals:
    void ButtonSignal(struct ControlCommand);
    void historyDataReady(); // 新增信号
private slots:
    void dataUpSlot(const QByteArray&);
    void DataDownSlot();
    void cntlDownSlot(const struct ControlCommand& cmd);
    void getJSON(QString &json);
    void deviceInit();
    void nodejson(QString& node);
    void ButtonSlot(bool);
    void historySlot();
    void modeSlot();
    QString tocntlJSON(const ControlCommand& cmd);

};

#endif // DEVICE_DATA_H
